<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增账户入账申请')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-record-add">


            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">入账的账户信息：</label>
                <div class="col-sm-8" id="itemAccount">
                    <div  class="col-sm-4">
                        <select name="itemAccountType" class="type form-control m-b" data-first-title="请选择">
                            <option value="">请选择</option>
                        </select>
                    </div>
                    <div class="col-sm-4">
                        <select name="itemAccountId" class="router form-control m-b" data-first-title="请选择">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">账单日期：</label>
                <div class="col-sm-8">
                    <input name="billDateInfo" id="billDateInfo" class="form-control" type="text" required>
                    <span style="color: red">说明：会将该账单入账到选择的日期</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">操作类型：</label>
                <div class="col-sm-8">
                    <select name="actionType" class="form-control">
                        <option  th:each="item:${actionTypeList}" th:text="${item.name}" th:value="${item.value}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">总账户信息：</label>
                <div class="col-sm-8">
                    <select name="mainAccountId" class="form-control">
                        <option value="0">暂无</option>
                        <option  th:each="item:${accountInfoList}" th:text="${item.name}" th:value="${item.value}"></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">入账金额：</label>
                <div class="col-sm-8">
                    <input name="billAmount" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注信息：</label>
                <div class="col-sm-8">
                    <textarea name="remarkInfo" class="form-control"></textarea>
                    <span style="color: red">说明：退款填写对方账号信息</span>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">入账图片：</label>
                <div class="col-sm-8">
                    <img alt="[入账图片]" width="90px" height="60px"  src="" id="imageUrl_img">
                    <input name="imgUrl" id="imageUrl" class="form-control" type="hidden" required>
                    <input id="inputImage" name="file" type="file">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: jquery-cxselect-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:inline="javascript">
        var prefix = ctx + "account/record"
        $("#form-record-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/add", $('#form-record-add').serialize());
            }
        }

        layui.use('laydate', function(){
            var laydate = layui.laydate;

            laydate.render({
                elem: '#billDateInfo',
                type: 'date',
                value: new Date()
            });
        });

        var data = [[${itemAccountList}]];
        $('#itemAccount').cxSelect({
            selects: ['type', 'router'],
            jsonValue: 'v',
            data: data
        });

        $(document).ready(function () {
            // 单图上传
            $("#inputImage").fileinput({
                uploadUrl: ctx + 'common/upload/bill',
                maxFileCount: 1,
                autoReplace: true
            }).on('fileuploaded', function (event, data, previewId, index) {
                var rsp = data.response;
                // log.info("return url：" + rsp.url)
                // log.info("reutrn fileName：" + rsp.fileName)
                // log.info("reutrn newFileName：" + rsp.newFileName)
                // log.info("return originalFilename：" + rsp.originalFilename)
                $("#imageUrl").val(rsp.fileUrl)
                $("#imageUrl_img").attr("src", rsp.fileUrl)
            }).on('fileremoved', function (event, id, index) {
                $("input[name='" + event.currentTarget.id + "']").val('')
            })
        });




    </script>
</body>
</html>